/* -*- C++ -*- */
/*===========================================================
 
 .---=||||[ B L O O D Y ]|||||=====================----------....
 |                                                              |
 |    THE  M O S T   B L O O D Y  GAME EVER!                    |
 |                                                              |
 |    bloody harvest is coming... soon,                         |
 |                                              heil Satan!     |
 !                                                              !
 .                                                              ,
  ~~~~-------------================================|||||||||==-~




	Name-Space: {core, logic, editor}
	Module: {draw, coll, scgr, ...}
	Class: <name of class>
	Last modification:  <author>, <time>

	TODO:
	<-------- todo #1 ---------->
	<-------- todo #2 ---------->
	<-------- todo #3 ---------->
	............
	<-------- todo #n ---------->

	FIX:
	<-------- fix #1 ----------->
	<-------- fix #1 ----------->
	..........
	<-------- fix #n ----------->




 
 
	============================================================*/
#ifndef __draw_Device_Header_File__
#define __draw_Device_Header_File__

#include "common.h"
#include "core/draw/Light.h"
#include "core/draw/Texture.h"
#include "core/draw/Font.h"
#include "core/draw/TextureManager.h"
#include "core/evnt/Mouse.h"
#include "core/evnt/Keyboard.h"


namespace core
{
   namespace draw
   {


      /**
       * This class is wrapper over OpenGL graphics device. You can 
       * access this device mostly by using methods, that this class 
       * provides. 
       */
      class Device
      {
	    TextureManager* textureManager;
	    SDL_Surface* screen;
	    Font* font;

	    u32 nLights;
	    std::vector<Light> lights;
	
	
	 public:
	    /**
	     * Creates new OpenGL device.
	     * @param initialize if set to true, this will also call
	     * init method.
	     */
	    Device(bool initialze);
	    
	    /**
	     * Destroys device and its data.
	     */
	    virtual ~Device();
	
	    /**
	     * Initialze system.
	     */
	    void init();

	    /**
	     * Initialize GL subsystem
	     */
	    void initGL();
	
	    /**
	     * Creates window.
	     *
	     * @param w Width of window.
	     * @param h Height of window
	     * @param fullscreen Use fullscreen mode
	     */
	    void createWindow(int w, int h, bool fullscreen = false);
	
	    /**
	     * Gets texture manager
	     */
	    TextureManager& getTextureManager(){ return *textureManager; }
	
	    /**
	     * Gets system default font
	     */
	    
 
	    Font& getFont(){ return *font; }

	    /**
	     * begins scene
	     */
	    void beginScene();

	    /**
	     * Setup OpenGL state matrices
	     */
	    void setupMatrices();

	    /**
	     * ends scene
	     */
	    void endScene();

	    /**
	     * Gets light object.
	     * @param n Number of light in 0..7 (commonly)
	     */
	    Light& light(u32 n)
	    { 
	       assert(n >= 0 && n <= nLights); 
	       return lights[n]; 
	    }

	    /**
	     * Gets light object.
	     * @param n Number of light in 0..7 (commonly)
	     */
	    const Light& light(u32 n) const 
	    { 
	       assert(n >= 0 && n <= nLights); 
	       return lights[n]; 
	    }
      };

   }
}

#endif // __draw_Device_Header_File__

